package com.sky.kafkaDemo.controller;

import com.sky.kafkaDemo.entity.User;
import com.sky.kafkaDemo.service.impl.KafkaProducerServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/kafka")
public class KafkaController {

    @Autowired
    private KafkaProducerServiceImpl producerService;

    @PostMapping("/send")
    public String sendMessage(@RequestParam String message) {
        producerService.sendMessage(message);
        return "消息发送成功: " + message;
    }

    @PostMapping("/sendUser")
    public String sendUser(@RequestBody User user) {
        producerService.sendUser(user);
        return "用户信息发送成功: " + user.getUserName();
    }

}